﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Web.Mvc;

namespace MobiShop.Models
{
    public class AppSetting
    {
        public static readonly string DefaultImage = ConfigurationManager.AppSettings["DefaultImage"];

        public static List<SelectListItem> VisibleListItem = GeneralVisibleListItem();

        public static List<SelectListItem> GeneralVisibleListItem()
        {
            List<SelectListItem> list = new List<SelectListItem>();
            SelectListItem item = new SelectListItem();
            item.Text = "Tất cả";
            item.Value = "";
            list.Add(item);

            item = new SelectListItem();
            item.Text = "Kích hoạt";
            item.Value = "true";
            list.Add(item);
            item.Selected = true;

            item = new SelectListItem();
            item.Text = "Đã bị xóa";
            item.Value = "false";
            list.Add(item);

            return list;
        }

        public static List<SelectListItem> Make_Clone(List<SelectListItem> original, string selectedValue)
        {
            List<SelectListItem> list = new List<SelectListItem>();
            SelectListItem newItem;
            foreach (SelectListItem item in original)
            {
                newItem = new SelectListItem();
                newItem.Text = item.Text;
                newItem.Value = item.Value;
                list.Add(newItem);
                if (newItem.Value == selectedValue)
                    newItem.Selected = true;
            }
            return list;
        }

        public static List<SelectListItem> GeneralRoleListItem()
        {
            List<SelectListItem> list = new List<SelectListItem>();
            SelectListItem item = new SelectListItem();
            item.Text = "Tất cả";
            item.Value = "";
            list.Add(item);

            item = new SelectListItem();
            item.Text = "User";
            item.Value = "1";
            list.Add(item);

            item = new SelectListItem();
            item.Text = "Admin";
            item.Value = "2";
            list.Add(item);

            return list;
        }
    }
}